<template>
   <el-form :inline="true">
    <el-form-item label="搜索">
      <el-input v-model="searchBar.key" placeholder="输入菜品" />
    </el-form-item>
    <el-form-item label="日期">
      <el-date-picker
        v-model="dateRange"
        type="daterange"
        unlink-panels
        value-format="YYYY-MM-DD"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        :shortcuts="shortcuts"
        :size="size"
      />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSearch" icon="Search">搜索</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  data () {
    return {
      dateRange: [],
      searchBar: {
        key: '',
        start: '',
        end: ''
      }
    }
  },
  methods: {
    onSearch () {
      this.searchBar.start = this.dateRange[0]
      this.searchBar.end = this.dateRange[1]
      this.$emit('onSeach', this.searchBar)
      console.log(this.searchBar)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
